package com.sk.sourcecircle.activity.home.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.sk.sourcecircle.R;
import com.sk.sourcecircle.base.BaseActivity;
import com.sk.sourcecircle.utils.MyUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by sk on 2018/1/2.
 */

public class ChangeBuyInfoActivity extends BaseActivity {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.finish)
    TextView finish;
    @BindView(R.id.ed_name)
    EditText edName;
    @BindView(R.id.ed_phone)
    EditText edPhone;

    @Override
    protected int getContentView() {
        return R.layout.activity_change_buy_person_info;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        edName.setText(MyUtils.getMyInfo(mContext).getNickname());
        edPhone.setText(MyUtils.getMyInfo(mContext).getPhone());
    }

    @OnClick({R.id.back, R.id.finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.finish:
                List<EditText> editTexts = new ArrayList<>();
                edName.setTag("请填写购买人姓名。");
                edPhone.setTag("请填写购买人联系方式。");
                editTexts.add(edName);
                editTexts.add(edPhone);
                if(MyUtils.isFormat(mRootView,editTexts)){
                    Intent intent = new Intent();
                    intent.putExtra("name",edName.getText().toString());
                    intent.putExtra("phone",edPhone.getText().toString());
                    setResult(RESULT_OK,intent);
                    finish();
                }
                break;
        }
    }
}
